package cnedu.ncist.uploadtest.web;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import edu.ncist.wang.hkdf.bussiness.blo.AbstractFlowHandler;
import edu.ncist.wang.hkdf.dao.database.DBConnectionException;
import edu.ncist.wang.hkdf.dao.database.DataBaseAccess;
import edu.ncist.wang.hkdf.dao.database.DataManipulationException;

public class UploadtestFlowHandler extends AbstractFlowHandler{

	public String doFlowProcess(Map paraMap) {
		// TODO Auto-generated method stub
		String actionType = (String)paraMap.get("ACTIONTYPE");
		if("testfileup".equals(actionType)){
			return testfileup(paraMap);
		}/*else if("job_Init".equals(actionType)){
			return job_init(paraMap);
		}*/
		else{
			ActionTypeError();
		}
		return null;
	}

	public String testfileup(Map paraMap) {
		// TODO Auto-generated method stub
		HttpServletRequest request = (HttpServletRequest)paraMap.get("REQUEST");
		HttpServletResponse response = (HttpServletResponse)paraMap.get("RESPONSE");
		Map map = (Map)paraMap.get("RESULTMAP");
//		request.setAttribute("UPLOADINFO", map.get("UPLOADINFO"));
//		request.setAttribute("CONDITIONMAP", map.get("CONDITIONMAP"));
		request.setAttribute("CONDITIONMAP", map.get("upload"));
		request.setAttribute("INFO1", map.get("INFO1"));
		request.setAttribute("INFO2", map.get("INFO2"));
		String deleinfo="delete from info where 1=1";
		DataBaseAccess dba = (DataBaseAccess)request.getAttribute("AUTHDATACONNECTION");
		try {
			//dba.executeUpdate(deleinfo);
			dba.close();
		} catch (DBConnectionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return (String)map.get("RESULT");
	}
	
}
